<?php 
namespace Common\Model;

/**
 * 客栈预定端掌柜说信息表
 * 
 * @index hotelId(`hotelentity_id`)
 */

Class HotelDetailModel extends \Common\Model\BaseModel
{
	protected $trueTableName = 'bk_hotel_detail';
	protected $field = 'id,hotelentity_id,special,specialimageurl,isactive,isdelete';
	/**
     * 根据$hotelId获取多套个性推荐信息
     * 
     * @return array              执行结果
     */
	public function getNameByHotel($hotelId) {
		$option = array(
			'hotelentity_id' => $hotelId,
			'isdelete' => 0,
		);		
		return $this->where($option)->getField('name');
	}

	/**
     * @return array              执行结果
     */
	public function getHotelInfo($hotelId) {
		if (is_array($hotelId)) {
			$hotelId = implode(',', $hotelId);
		}

		if (strpos($hotelId, ',') !== false) {
			$hotelId = array('in', $hotelId);
		} else {
			$hotelId = $hotelId;
		}

		$option = array(
			'hotelentity_id' => $hotelId,
			'isdelete' => 0,
			'enddate' => array('gt' , date('Y-m-d')),
		);

		$field = 'hotelentity_id,name,logoimageurl';
		return $this->field($field)->where($option)->select();
	}
	
	public function getShareStatus($hotelId) {
	    $option = array(
	        'hotelentity_id' => $hotelId,
	        'isdelete' => 0,
	    );
	    return $this->where($option)->getField('sharekey');
	}
	
}